{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {
    "collapsed": true,
    "pycharm": {
     "name": "#%% md\n"
    }
   },
   "source": [
    "\n",
    "# 线性回归的简洁实现\n",
    "\n",
    "随着深度学习框架的发展，开发深度学习应用变得越来越便利。实践中，我们通常可以用比上一节更简洁的代码来实现同样的模型。在本节中，我们将介绍如何使用tensorflow2.0推荐的keras接口更方便地实现线性回归的训练。\n",
    "\n",
    "## 生成数据集\n",
    "\n",
    "我们生成与上一节中相同的数据集。其中`features`是训练数据特征，`labels`是标签。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "pycharm": {
     "is_executing": false,
     "name": "#%%\n"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "tf.Tensor([-0.36099175  0.8862902 ], shape=(2,), dtype=float32) tf.Tensor(1.5807515, shape=(), dtype=float32)\n"
     ]
    }
   ],
   "source": [
    "import tensorflow as tf\n",
    "num_inputs = 2\n",
    "num_examples = 1000\n",
    "true_w = [2, -3.4]\n",
    "true_b = 4.2\n",
    "features = tf.random.normal([num_examples, num_inputs],mean=0,stddev=1)\n",
    "labels = true_w[0] * features[:, 0] + true_w[1] * features[:, 1] + true_b\n",
    "labels += tf.random.normal(labels.shape,0,1)\n",
    "print(features[0], labels[0])"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "pycharm": {
     "name": "#%% md\n"
    }
   },
   "source": [
    "虽然tensorflow2.0对于线性回归可以直接拟合，不用再划分数据集，但我们仍学习一下读取数据的方法"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "pycharm": {
     "name": "#%%\n"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "tf.Tensor(\n",
      "[[-0.36099175  0.8862902 ]\n",
      " [-0.1839203   0.69210005]\n",
      " [ 0.9376471  -1.8326032 ]\n",
      " [-0.8767882   0.06162997]\n",
      " [ 2.0317926   1.1839459 ]\n",
      " [ 0.14049357 -0.06233747]\n",
      " [ 0.2712547  -1.0112672 ]\n",
      " [-0.9887581   1.0038339 ]\n",
      " [-1.5709177   0.6849357 ]\n",
      " [ 1.4573355   0.14634162]], shape=(10, 2), dtype=float32) tf.Tensor(\n",
      "[ 1.5807515   2.0043135  11.38282     1.9067247   3.3788707   4.174027\n",
      "  9.1142845  -0.3445133   0.72452116  6.381167  ], shape=(10,), dtype=float32)\n",
      "tf.Tensor(\n",
      "[[ 0.67836106  0.21218857]\n",
      " [ 0.7805339   0.1751083 ]\n",
      " [-0.40067694  0.01032858]\n",
      " [-0.5874898  -0.23388049]\n",
      " [ 1.7244262   0.12885976]\n",
      " [-0.36420974  0.8306901 ]\n",
      " [-0.67727995 -0.42827734]\n",
      " [ 0.32643402 -0.31216484]\n",
      " [-1.6838305   0.02156664]\n",
      " [ 0.9449985   0.92415   ]], shape=(10, 2), dtype=float32) tf.Tensor(\n",
      "[5.158974  5.8439374 2.4597278 4.726387  7.7726755 1.1911871 6.674436\n",
      " 5.978803  2.1197748 4.261552 ], shape=(10,), dtype=float32)\n",
      "tf.Tensor(\n",
      "[[ 0.45266736  0.5006    ]\n",
      " [-1.8639725   1.0549592 ]\n",
      " [-0.57845616 -1.5595229 ]\n",
      " [ 0.15952802 -0.01974652]\n",
      " [-0.9748379   0.02575157]\n",
      " [ 1.8849461  -2.1342072 ]\n",
      " [ 0.43049768  1.3897038 ]\n",
      " [-1.1582334   1.4121163 ]\n",
      " [-3.0951474  -0.8397087 ]\n",
      " [ 0.10973429  0.05760803]], shape=(10, 2), dtype=float32) tf.Tensor(\n",
      "[ 0.91739225 -2.4668512   7.963223    5.338704    1.6127717  15.641377\n",
      "  2.228479   -2.1138585   0.3287133   4.1898556 ], shape=(10,), dtype=float32)\n",
      "tf.Tensor(\n",
      "[[ 1.4353232  -0.5772899 ]\n",
      " [ 0.99772453 -0.5407365 ]\n",
      " [-0.10278049  1.0432203 ]\n",
      " [-0.03546245  0.49322414]\n",
      " [-1.0136113  -1.2380587 ]\n",
      " [-0.31792915  1.2143193 ]\n",
      " [-1.9021229  -1.2285212 ]\n",
      " [ 0.95114535 -1.432955  ]\n",
      " [-0.7026368   1.287353  ]\n",
      " [ 0.36842176  0.36120337]], shape=(10, 2), dtype=float32) tf.Tensor(\n",
      "[ 9.010688    9.017536    0.6005234   2.0630882   6.9599495   0.65049374\n",
      "  5.2313113  10.434232   -1.284886    3.5618804 ], shape=(10,), dtype=float32)\n",
      "tf.Tensor(\n",
      "[[-1.1676772  -0.5861256 ]\n",
      " [ 0.5075711  -0.6231087 ]\n",
      " [-0.37726775  0.07329043]\n",
      " [ 0.43696228 -1.5733198 ]\n",
      " [-0.64884853  0.21844569]\n",
      " [-1.0629351  -0.18794204]\n",
      " [-0.24859475 -0.6082256 ]\n",
      " [-0.70008343 -1.8335236 ]\n",
      " [-0.60702175  0.7206166 ]\n",
      " [ 0.56332666  0.04687001]], shape=(10, 2), dtype=float32) tf.Tensor(\n",
      "[ 4.4376287   7.8055816   5.060627    9.235688    1.5668464   3.6397698\n",
      "  6.316183    8.273059   -0.80592644  7.1101933 ], shape=(10,), dtype=float32)\n",
      "tf.Tensor(\n",
      "[[ 0.6551521  -0.7879127 ]\n",
      " [ 0.1540543  -0.46936417]\n",
      " [-0.05754626  0.84510463]\n",
      " [-0.6878642   1.9716971 ]\n",
      " [-0.12272443  1.8684355 ]\n",
      " [ 0.65151393 -0.3547168 ]\n",
      " [ 1.0450255  -1.4274879 ]\n",
      " [-1.1889154   0.12673305]\n",
      " [-0.77551836 -0.31261095]\n",
      " [ 0.30755877  1.0512182 ]], shape=(10, 2), dtype=float32) tf.Tensor(\n",
      "[ 6.52345     7.085485    2.5612257  -3.76099    -2.1881878   6.6991982\n",
      " 10.793392    0.5562233   3.1779962   0.19056118], shape=(10,), dtype=float32)\n",
      "tf.Tensor(\n",
      "[[-0.26653084  0.62704927]\n",
      " [-0.3188962   0.28537023]\n",
      " [-1.0270444  -1.187873  ]\n",
      " [-1.9937987  -0.9377441 ]\n",
      " [ 1.396246   -0.09418255]\n",
      " [ 0.96017057 -0.683984  ]\n",
      " [ 1.213069    2.3103406 ]\n",
      " [ 0.7273747   0.2684342 ]\n",
      " [-0.90661114 -2.763183  ]\n",
      " [-1.2251344  -0.8096157 ]], shape=(10, 2), dtype=float32) tf.Tensor(\n",
      "[-0.42105508  3.36088     4.4785514   4.7005363   7.461465    9.09955\n",
      " -0.4930179   3.745862   12.428754    4.5986238 ], shape=(10,), dtype=float32)\n",
      "tf.Tensor(\n",
      "[[-1.0867667   0.3725584 ]\n",
      " [-0.07715927  0.950818  ]\n",
      " [-0.07824782  0.4241756 ]\n",
      " [-0.94013995 -0.2692202 ]\n",
      " [ 0.42702633  2.2702434 ]\n",
      " [-0.08959255  1.3078309 ]\n",
      " [-0.91098624 -1.7646434 ]\n",
      " [-0.77293193 -0.22440208]\n",
      " [ 0.7765234   1.4354843 ]\n",
      " [ 0.33968103 -0.08194025]], shape=(10, 2), dtype=float32) tf.Tensor(\n",
      "[ 0.36423856 -0.68402267  3.745622    4.410675   -3.9970884  -0.37510765\n",
      "  9.104534    2.5259783   2.0234091   6.699661  ], shape=(10,), dtype=float32)\n",
      "tf.Tensor(\n",
      "[[-0.9479695  -1.4745225 ]\n",
      " [ 0.5835935  -1.9995229 ]\n",
      " [ 0.4230877  -0.745933  ]\n",
      " [ 0.1391792  -0.09517506]\n",
      " [ 1.7888713   0.74619025]\n",
      " [-1.7489835  -0.14116712]\n",
      " [ 0.37459582  0.81463176]\n",
      " [ 0.08679591 -1.5443951 ]\n",
      " [-0.45608714 -1.308572  ]\n",
      " [ 0.3608902  -2.0239716 ]], shape=(10, 2), dtype=float32) tf.Tensor(\n",
      "[ 6.604844  11.445588   5.987379   5.6427445  4.6866245  1.8947494\n",
      "  3.2137034  8.801286   7.9994874 12.100541 ], shape=(10,), dtype=float32)\n",
      "tf.Tensor(\n",
      "[[ 0.7799546  -0.43757674]\n",
      " [ 0.4742707   0.23856129]\n",
      " [ 1.627279    0.3678523 ]\n",
      " [ 0.9060334   1.049478  ]\n",
      " [-1.4961573   0.05330886]\n",
      " [-0.19475172 -0.11208288]\n",
      " [-0.9678449  -1.1011568 ]\n",
      " [ 0.38059476  0.6718918 ]\n",
      " [-0.8700606  -0.9198152 ]\n",
      " [-0.12414318  0.9254849 ]], shape=(10, 2), dtype=float32) tf.Tensor(\n",
      "[7.875467  3.661924  7.148671  1.6154332 1.5606611 4.3731713 5.1017666\n",
      " 2.6576319 3.9164448 1.7376921], shape=(10,), dtype=float32)\n",
      "tf.Tensor(\n",
      "[[-1.0761168   0.02369363]\n",
      " [-0.6500461  -1.2790196 ]\n",
      " [ 1.1591263   0.98660123]\n",
      " [ 0.99331695 -0.15368685]\n",
      " [-0.47161     2.2036119 ]\n",
      " [ 0.36716053  0.8847503 ]\n",
      " [-0.5990257   0.24067597]\n",
      " [ 2.4322157  -0.13072233]\n",
      " [-0.33724073 -0.11008205]\n",
      " [ 0.25129086  0.22355612]], shape=(10, 2), dtype=float32) tf.Tensor(\n",
      "[ 2.1038399  6.609107   3.3854156  7.111263  -3.9592328  2.8360307\n",
      "  2.151696   9.7524185  3.8504937  3.4177942], shape=(10,), dtype=float32)\n",
      "tf.Tensor(\n",
      "[[-0.03437785 -0.72965926]\n",
      " [-0.40038422  0.07440113]\n",
      " [ 1.1153682   0.3251533 ]\n",
      " [ 1.1459951   1.2616429 ]\n",
      " [ 0.30068094 -0.5734283 ]\n",
      " [ 0.12822284  1.3755454 ]\n",
      " [ 0.7024656   0.00598521]\n",
      " [-0.72026944 -0.68660164]\n",
      " [-1.7032133   0.2906555 ]\n",
      " [ 1.326967   -0.92668676]], shape=(10, 2), dtype=float32) tf.Tensor(\n",
      "[ 8.141883    4.2910895   3.7737389   1.1502032   5.3578615  -0.02640682\n",
      "  5.4641824   5.699517    1.0755941   9.791576  ], shape=(10,), dtype=float32)\n",
      "tf.Tensor(\n",
      "[[-0.81990695 -0.19986254]\n",
      " [-0.12931627  2.6926534 ]\n",
      " [ 0.05690108  1.0972805 ]\n",
      " [ 0.70906615 -0.7628804 ]\n",
      " [-0.3785099  -0.7236207 ]\n",
      " [ 1.8058861   0.47196758]\n",
      " [ 0.25269276  0.9889579 ]\n",
      " [-0.01042559  0.1633536 ]\n",
      " [-0.6955577  -1.2217703 ]\n",
      " [-1.157348   -0.38549706]], shape=(10, 2), dtype=float32) tf.Tensor(\n",
      "[ 4.437541   -3.3272014   0.80224705  8.659284    4.8811145   5.555714\n",
      "  0.82509637  2.8786745   5.5061655   3.6572666 ], shape=(10,), dtype=float32)\n",
      "tf.Tensor(\n",
      "[[ 0.62801695 -0.79871744]\n",
      " [ 1.3732395  -0.46277905]\n",
      " [-1.0436847  -0.8975859 ]\n",
      " [ 1.2650758  -1.0939403 ]\n",
      " [ 0.7689468   0.60840183]\n",
      " [-0.7609887   1.0516949 ]\n",
      " [ 0.707386   -0.20239995]\n",
      " [ 0.9896434  -0.13632244]\n",
      " [ 1.185901    0.1948412 ]\n",
      " [ 0.48088124  0.14595322]], shape=(10, 2), dtype=float32) tf.Tensor(\n",
      "[ 7.33347     7.8399277   4.228105   10.109852    2.5129426   0.09832639\n",
      "  7.391395    6.863874    5.6660337   3.9014697 ], shape=(10,), dtype=float32)\n",
      "tf.Tensor(\n",
      "[[-0.23297891  1.2649424 ]\n",
      " [ 0.8952558  -0.9186914 ]\n",
      " [ 1.5227499   1.8598098 ]\n",
      " [ 0.6869424   0.8324365 ]\n",
      " [-0.68137443  1.4243944 ]\n",
      " [ 0.73814726 -0.84854305]\n",
      " [ 2.3219779   1.686461  ]\n",
      " [-0.36122775 -0.10729692]\n",
      " [-1.5037264  -0.2588322 ]\n",
      " [-0.7992902   1.5296974 ]], shape=(10, 2), dtype=float32) tf.Tensor(\n",
      "[-0.9046161   8.373634    1.4325426   3.267136   -0.37626636  9.11529\n",
      "  2.6880758   3.7618008   2.898682   -1.602432  ], shape=(10,), dtype=float32)\n",
      "tf.Tensor(\n",
      "[[ 1.0309058  -1.4287897 ]\n",
      " [-1.298594    0.13565186]\n",
      " [ 1.5968206   0.08564916]\n",
      " [-0.0638717   0.45347446]\n",
      " [ 0.9532507  -0.0788855 ]\n",
      " [-2.2448556  -0.375605  ]\n",
      " [ 1.8635207   0.06030997]\n",
      " [-0.19325618  1.9236    ]\n",
      " [-0.8631526   0.99567294]\n",
      " [-0.03103086  0.94418454]], shape=(10, 2), dtype=float32) tf.Tensor(\n",
      "[12.493778    0.0932523   7.953106    2.4528716   4.684972   -0.47311282\n",
      "  7.1962757  -2.5650527  -0.01561594  1.4543853 ], shape=(10,), dtype=float32)\n",
      "tf.Tensor(\n",
      "[[ 0.09174331  0.28771147]\n",
      " [ 1.0646049  -1.8718358 ]\n",
      " [-0.29158404 -0.0499787 ]\n",
      " [-0.38910127  0.46938613]\n",
      " [-0.9500659  -0.4643271 ]\n",
      " [ 0.82609564  1.3065516 ]\n",
      " [ 2.4001002   0.41047043]\n",
      " [-1.7099699  -1.50883   ]\n",
      " [ 0.3389523   0.4941298 ]\n",
      " [-0.20397565 -0.05597544]], shape=(10, 2), dtype=float32) tf.Tensor(\n",
      "[ 3.4861596  12.774063    2.6884418   0.59427524  3.2519667   1.5074471\n",
      "  7.608122    6.5822845   0.5474992   3.6659324 ], shape=(10,), dtype=float32)\n",
      "tf.Tensor(\n",
      "[[ 0.03456883  1.6602783 ]\n",
      " [-1.1937248   0.8707322 ]\n",
      " [ 0.6747647   0.30563888]\n",
      " [ 0.38877153 -0.20966008]\n",
      " [-0.5119327  -0.33362764]\n",
      " [-0.7083641   0.07974749]\n",
      " [-0.49269533 -1.9534676 ]\n",
      " [-1.0212046  -0.714555  ]\n",
      " [-1.1513277  -0.05199666]\n",
      " [ 0.02060214  0.33854362]], shape=(10, 2), dtype=float32) tf.Tensor(\n",
      "[-1.0187811  -0.05612373  3.7178123   7.4187684   3.2845592   2.0185928\n",
      " 10.611615    5.1603727   1.6487113   3.2187276 ], shape=(10,), dtype=float32)\n",
      "tf.Tensor(\n",
      "[[-0.26008445 -0.85262465]\n",
      " [-0.37403524  0.2594802 ]\n",
      " [-0.4590469   0.23660998]\n",
      " [ 0.4803721  -1.4905204 ]\n",
      " [ 1.1066209  -1.6787505 ]\n",
      " [ 0.41331258 -0.37890056]\n",
      " [ 0.17940731 -0.27953035]\n",
      " [ 1.1604079   0.72240376]\n",
      " [-0.16864358 -0.5526901 ]\n",
      " [-0.02726598 -0.8076848 ]], shape=(10, 2), dtype=float32) tf.Tensor(\n",
      "[ 5.6310096  1.122346   2.418689  11.185153  12.427194   8.417197\n",
      "  6.561759   4.276709   5.5814204  7.59546  ], shape=(10,), dtype=float32)\n",
      "tf.Tensor(\n",
      "[[ 0.62854207 -1.0195975 ]\n",
      " [ 1.0349385  -1.06114   ]\n",
      " [ 0.9954159  -0.69227254]\n",
      " [-1.0260326   0.881106  ]\n",
      " [-0.5593731   0.27681226]\n",
      " [-1.3352691   2.7007859 ]\n",
      " [ 1.7396733   1.2772946 ]\n",
      " [-0.9885546   1.0490246 ]\n",
      " [-2.4766605  -0.30188602]\n",
      " [ 0.6721825   0.9732785 ]], shape=(10, 2), dtype=float32) tf.Tensor(\n",
      "[ 7.919437   11.401338    7.541918    0.6040369   0.21321225 -8.020302\n",
      "  3.2281046  -0.45559168  0.71028453  3.8405328 ], shape=(10,), dtype=float32)\n",
      "tf.Tensor(\n",
      "[[-2.3231096  -0.58540916]\n",
      " [ 1.5526621   1.2275492 ]\n",
      " [-0.551045    1.5037007 ]\n",
      " [ 1.3640573  -0.50174874]\n",
      " [ 1.6383286  -1.1385099 ]\n",
      " [-2.1802773  -1.6683097 ]\n",
      " [ 0.84717304  1.4636117 ]\n",
      " [ 0.64168364 -0.4880872 ]\n",
      " [ 0.465983    0.9004167 ]\n",
      " [-1.7649653  -0.07813387]], shape=(10, 2), dtype=float32) tf.Tensor(\n",
      "[ 2.9680438  2.459331  -1.5533099  7.250437  10.643658   6.8562098\n",
      "  0.5717764  7.6143937  1.7408689  2.5257006], shape=(10,), dtype=float32)\n",
      "tf.Tensor(\n",
      "[[ 7.5843465e-01 -1.1231558e+00]\n",
      " [-8.6120844e-01  6.8996388e-01]\n",
      " [ 1.1038077e+00  9.0946141e-04]\n",
      " [-7.7959621e-01  6.8628006e-02]\n",
      " [ 1.3778534e+00  1.2689092e+00]\n",
      " [ 1.0803961e+00  9.4445300e-01]\n",
      " [ 2.6434617e+00  1.2933345e+00]\n",
      " [ 2.0144245e-01  1.3719879e+00]\n",
      " [-2.0103571e-01  1.2513306e+00]\n",
      " [-4.3960503e-01  1.9064844e-01]], shape=(10, 2), dtype=float32) tf.Tensor(\n",
      "[10.054221   -0.46057796  7.538542    1.9528699   0.64665055  2.3431828\n",
      "  5.0466413   1.6042013   1.925426    3.4736254 ], shape=(10,), dtype=float32)\n",
      "tf.Tensor(\n",
      "[[-0.40423116 -0.786885  ]\n",
      " [-0.01915775  0.24884696]\n",
      " [-0.10771295  1.020689  ]\n",
      " [-0.81169873 -0.8166628 ]\n",
      " [ 1.3814553   0.5007264 ]\n",
      " [ 1.0522012  -0.10266686]\n",
      " [-0.8409983  -1.4516672 ]\n",
      " [ 0.00902512  0.03908409]\n",
      " [ 2.3975182  -0.33287093]\n",
      " [-2.413328   -0.9408867 ]], shape=(10, 2), dtype=float32) tf.Tensor(\n",
      "[6.5338783  5.110696   0.22571471 5.2721725  5.2041516  5.082607\n",
      " 7.404426   6.6286573  9.871444   3.5291793 ], shape=(10,), dtype=float32)\n",
      "tf.Tensor(\n",
      "[[-0.6087359   0.02660983]\n",
      " [ 0.43311423  1.4159575 ]\n",
      " [ 1.1764028   2.0489743 ]\n",
      " [-0.8130387   1.5121107 ]\n",
      " [ 1.0081484  -0.44023803]\n",
      " [-1.3574629   0.97254276]\n",
      " [-0.01796985 -1.3621453 ]\n",
      " [ 1.3446295   0.27151874]\n",
      " [ 0.81922626  0.38708225]\n",
      " [-0.18265456 -0.35521936]], shape=(10, 2), dtype=float32) tf.Tensor(\n",
      "[ 3.3635075  0.4958177 -0.5311909 -2.1066484  5.482627  -1.1501734\n",
      "  7.714685   6.4909163  4.249969   5.481026 ], shape=(10,), dtype=float32)\n",
      "tf.Tensor(\n",
      "[[-1.6712124  -0.697273  ]\n",
      " [ 0.8640352  -0.8555037 ]\n",
      " [ 0.7586263   0.12019411]\n",
      " [ 0.41039512  0.20665494]\n",
      " [-0.85446215  0.7253907 ]\n",
      " [ 0.75843966 -0.2923236 ]\n",
      " [ 0.02944522 -0.8830261 ]\n",
      " [-0.52587926 -0.03207008]\n",
      " [-0.19860378 -0.4040931 ]\n",
      " [ 0.09438813  0.37049088]], shape=(10, 2), dtype=float32) tf.Tensor(\n",
      "[ 1.8178602   7.2605934   4.6329713   5.167623   -0.15727231  4.633828\n",
      "  5.089766    2.274361    4.173167    1.6227257 ], shape=(10,), dtype=float32)\n",
      "tf.Tensor(\n",
      "[[ 0.8530029   0.1787525 ]\n",
      " [-2.2867427  -2.3557224 ]\n",
      " [ 0.20954901 -1.1183897 ]\n",
      " [ 0.44512752  0.5965117 ]\n",
      " [-1.6954523   0.6527567 ]\n",
      " [-0.4653794  -2.347072  ]\n",
      " [-1.4014463  -1.0209723 ]\n",
      " [-0.25600195 -1.9639941 ]\n",
      " [ 0.14328527  0.90452814]\n",
      " [-0.2657183  -0.4525992 ]], shape=(10, 2), dtype=float32) tf.Tensor(\n",
      "[ 4.621925   7.339839   9.132861   2.8572083 -1.800582  11.124394\n",
      "  4.7164044 10.245916   2.16391    3.2671309], shape=(10,), dtype=float32)\n",
      "tf.Tensor(\n",
      "[[ 0.57608426  0.50669616]\n",
      " [ 1.7644799  -0.96991956]\n",
      " [ 0.789872   -0.30923343]\n",
      " [-0.22728549  0.48958802]\n",
      " [ 0.7530598  -0.96647567]\n",
      " [-1.0399563   0.41764718]\n",
      " [ 0.6049584  -1.2097275 ]\n",
      " [ 0.9945927   0.41643116]\n",
      " [-0.8285967   1.4572955 ]\n",
      " [ 0.2271105   0.15557002]], shape=(10, 2), dtype=float32) tf.Tensor(\n",
      "[ 4.4252205  9.973462   5.660922   2.429225  10.139336   1.6058836\n",
      "  8.382989   5.079207  -1.7204087  3.4045026], shape=(10,), dtype=float32)\n",
      "tf.Tensor(\n",
      "[[ 1.7199106   0.70685065]\n",
      " [-0.7382139   0.58884734]\n",
      " [ 0.00242982 -0.9892964 ]\n",
      " [ 1.5781791   0.07530235]\n",
      " [-0.73801136  0.03831987]\n",
      " [-0.11888787  1.8065215 ]\n",
      " [ 0.50531     0.40662715]\n",
      " [-0.27826735 -0.09530012]\n",
      " [ 1.7955145   1.2756419 ]\n",
      " [-1.4865546  -0.12927455]], shape=(10, 2), dtype=float32) tf.Tensor(\n",
      "[ 4.23837   -0.6405966  7.5005217  8.214212   0.5674796 -2.1071274\n",
      "  4.6821914  3.8687687  2.1093931  2.7903295], shape=(10,), dtype=float32)\n",
      "tf.Tensor(\n",
      "[[-1.4909438   0.66846585]\n",
      " [-0.99568206 -1.6039115 ]\n",
      " [-0.09486928 -0.05719792]\n",
      " [-1.9960896  -0.82798433]\n",
      " [ 0.266036   -0.7572141 ]\n",
      " [-0.5826621  -0.6059587 ]\n",
      " [-0.27225956 -0.44595394]\n",
      " [-0.6007748  -1.7331966 ]\n",
      " [ 1.5709573  -2.5886383 ]\n",
      " [ 0.13490821  1.4611312 ]], shape=(10, 2), dtype=float32) tf.Tensor(\n",
      "[-0.16722393  6.4122496   3.40449     3.1143413   6.5412745   5.634132\n",
      "  6.278379    8.760122   17.762331   -1.2547762 ], shape=(10,), dtype=float32)\n",
      "tf.Tensor(\n",
      "[[ 0.51239944  1.3548592 ]\n",
      " [ 0.9789921   1.1194005 ]\n",
      " [-0.7180544   0.06180981]\n",
      " [-0.45390838 -0.32175076]\n",
      " [ 1.1491997  -1.2595752 ]\n",
      " [ 1.1022962   0.24381275]\n",
      " [-1.8362566   1.1228973 ]\n",
      " [ 2.1513696  -1.5587553 ]\n",
      " [-0.97070616 -0.5517321 ]\n",
      " [-0.44086593  2.0794048 ]], shape=(10, 2), dtype=float32) tf.Tensor(\n",
      "[-0.7622802  1.0146749  2.9112978  3.6630147 11.166941   5.0146246\n",
      " -2.6419635 13.892994   5.331695  -2.5851226], shape=(10,), dtype=float32)\n",
      "tf.Tensor(\n",
      "[[-1.3728744   0.48729   ]\n",
      " [-0.30408537  0.97126716]\n",
      " [ 0.43946192 -0.6523364 ]\n",
      " [ 0.62584037 -1.429374  ]\n",
      " [ 0.0364853   1.1247294 ]\n",
      " [ 0.28572425 -0.235771  ]\n",
      " [-1.6574118   0.9684467 ]\n",
      " [ 1.7441862   1.2643139 ]\n",
      " [ 0.9720957   0.22384931]\n",
      " [-0.90384644  0.3901157 ]], shape=(10, 2), dtype=float32) tf.Tensor(\n",
      "[ 1.2648869   0.84039867  7.888466    9.91522     1.8565127   6.2420664\n",
      " -3.7358608   2.5651128   6.4183106   0.7832202 ], shape=(10,), dtype=float32)\n",
      "tf.Tensor(\n",
      "[[-1.6646945   1.6027728 ]\n",
      " [-1.3540136  -0.3549045 ]\n",
      " [-0.31628442  0.8155904 ]\n",
      " [-0.7843169   2.2465026 ]\n",
      " [ 0.02450659  0.23401804]\n",
      " [ 1.2225808   1.0903883 ]\n",
      " [ 0.39344108  0.0801458 ]\n",
      " [ 1.0736029  -0.2560269 ]\n",
      " [-0.5956304  -0.9548782 ]\n",
      " [ 0.80525726  1.0917474 ]], shape=(10, 2), dtype=float32) tf.Tensor(\n",
      "[-4.209983   2.9467196  1.5742606 -4.798384   3.5314395  3.0205648\n",
      "  5.1892805  7.6617026  6.056478   0.8893999], shape=(10,), dtype=float32)\n",
      "tf.Tensor(\n",
      "[[-0.089596   -0.87008756]\n",
      " [ 0.06379694  0.94149774]\n",
      " [-0.47703138  0.4915817 ]\n",
      " [-0.54069376 -1.7999252 ]\n",
      " [-0.780721    0.26681334]\n",
      " [-0.5002346   0.37639737]\n",
      " [ 1.4404689   1.0839149 ]\n",
      " [ 0.2729939   0.01788056]\n",
      " [ 0.34384727  0.24226208]\n",
      " [-0.178438   -0.19672577]], shape=(10, 2), dtype=float32) tf.Tensor(\n",
      "[ 6.58219     1.76473     1.4423819  11.06198     2.5525904   0.11580038\n",
      "  2.8583598   5.175961    5.0325513   3.5768023 ], shape=(10,), dtype=float32)\n",
      "tf.Tensor(\n",
      "[[ 1.1051414  -0.91387486]\n",
      " [ 1.0565068   0.11093685]\n",
      " [ 0.24756932  0.77018434]\n",
      " [-0.31249917 -0.5909735 ]\n",
      " [ 1.7844611   0.23834577]\n",
      " [-0.99536544  0.19083114]\n",
      " [-0.7240182   1.198577  ]\n",
      " [-0.5699425  -3.2696104 ]\n",
      " [ 0.29352638 -0.77570343]\n",
      " [ 1.0164922  -0.56119084]], shape=(10, 2), dtype=float32) tf.Tensor(\n",
      "[ 9.631187   5.733767   3.2407568  4.380249   8.132015   2.1596856\n",
      " -2.7806792 15.067847   8.290167   7.133093 ], shape=(10,), dtype=float32)\n",
      "tf.Tensor(\n",
      "[[-0.12952419  0.47513387]\n",
      " [-1.6277931   1.1800865 ]\n",
      " [ 0.20196718 -0.02344258]\n",
      " [-0.50678563 -0.17475793]\n",
      " [-1.5454755  -1.0836983 ]\n",
      " [-0.7964019   0.32395306]\n",
      " [-0.2529292  -1.0660114 ]\n",
      " [ 0.26529855 -0.78878486]\n",
      " [-1.1818918  -2.3230753 ]\n",
      " [-1.2958934  -0.37258115]], shape=(10, 2), dtype=float32) tf.Tensor(\n",
      "[ 0.5289184  -0.91237783  5.425543    6.096245    3.3940053   1.1356754\n",
      "  6.4285326   6.8617654   9.614727    2.0141034 ], shape=(10,), dtype=float32)\n",
      "tf.Tensor(\n",
      "[[ 0.32703924 -1.9625444 ]\n",
      " [-0.50453395 -2.1112013 ]\n",
      " [-1.3216984   1.0339158 ]\n",
      " [ 0.5048238  -0.2083743 ]\n",
      " [-0.61702615 -0.33269238]\n",
      " [-1.4580002   0.44706976]\n",
      " [ 0.787036    0.24929167]\n",
      " [-2.2382329  -0.20547569]\n",
      " [-0.8163473  -1.6552398 ]\n",
      " [-1.2993529   1.0314263 ]], shape=(10, 2), dtype=float32) tf.Tensor(\n",
      "[12.618964   10.953644   -0.50423825  5.213298    4.4083724  -0.747041\n",
      "  4.2686234   0.1355049   9.554989   -2.0293567 ], shape=(10,), dtype=float32)\n",
      "tf.Tensor(\n",
      "[[ 0.73927325  0.7951794 ]\n",
      " [ 0.597065    0.48668092]\n",
      " [ 0.20783663  0.38478315]\n",
      " [ 0.44628564  2.3189728 ]\n",
      " [-0.840655    0.18174307]\n",
      " [ 0.16217555  0.9042022 ]\n",
      " [-0.920077    1.3302746 ]\n",
      " [-1.447455   -2.3614376 ]\n",
      " [-0.09833067 -0.73611623]\n",
      " [-0.43240976  1.55137   ]], shape=(10, 2), dtype=float32) tf.Tensor(\n",
      "[ 2.373689   3.7080863  1.792277  -0.4600041  1.7130578  2.0550175\n",
      " -1.3096323 10.022539   8.329092  -3.1191986], shape=(10,), dtype=float32)\n",
      "tf.Tensor(\n",
      "[[ 0.5899825   0.2625858 ]\n",
      " [-0.9912329   0.19206393]\n",
      " [-0.9282912   1.6148814 ]\n",
      " [ 0.12124976 -0.25378793]\n",
      " [-0.3521733   1.119868  ]\n",
      " [ 0.5245966   0.31897858]\n",
      " [ 1.7980744  -0.21584782]\n",
      " [-1.1379775   0.15516703]\n",
      " [-0.62713933 -0.25133327]\n",
      " [ 0.88526773 -0.538293  ]], shape=(10, 2), dtype=float32) tf.Tensor(\n",
      "[ 4.504709   1.4981021 -2.022726   5.226998   1.7517996  3.2206845\n",
      "  8.184202   1.2603102  5.1891065  7.733016 ], shape=(10,), dtype=float32)\n",
      "tf.Tensor(\n",
      "[[ 9.7010180e-02 -4.2860496e-01]\n",
      " [ 2.4655090e-01  5.5688643e-01]\n",
      " [-2.9204664e+00 -3.3913508e-01]\n",
      " [-1.4410316e+00 -1.0976717e+00]\n",
      " [ 6.3002646e-01  2.3170474e-03]\n",
      " [-1.3211905e+00 -5.1179236e-01]\n",
      " [ 1.0003558e+00  2.4907325e-01]\n",
      " [ 4.8665586e-01  1.0763956e+00]\n",
      " [ 1.5069454e+00  1.4155154e+00]\n",
      " [ 1.5870942e+00 -3.7437317e-01]], shape=(10, 2), dtype=float32) tf.Tensor(\n",
      "[ 6.133635   3.8776588 -0.5726665  4.4244347  5.6887136  2.910744\n",
      "  4.6376834  3.4883409  2.409538  11.328804 ], shape=(10,), dtype=float32)\n",
      "tf.Tensor(\n",
      "[[ 0.4676776   1.7583461 ]\n",
      " [ 1.7598879   0.30270743]\n",
      " [ 0.90140414  0.49973947]\n",
      " [-0.83008856  0.5867181 ]\n",
      " [ 0.76252174  0.15265019]\n",
      " [-0.0026032  -0.23220092]\n",
      " [-0.3822687  -1.1512117 ]\n",
      " [-0.6584279   1.0755327 ]\n",
      " [-1.0595993   2.261241  ]\n",
      " [ 0.01309142 -1.4287525 ]], shape=(10, 2), dtype=float32) tf.Tensor(\n",
      "[ 0.17700529  7.66652     3.4531364  -0.17120528  5.9001827   5.9561467\n",
      "  8.396654   -0.05171406 -5.7946424  10.019793  ], shape=(10,), dtype=float32)\n",
      "tf.Tensor(\n",
      "[[-0.2860222   1.3359865 ]\n",
      " [-0.8741996   0.10573681]\n",
      " [ 0.7520313  -0.5323413 ]\n",
      " [-0.09082411 -0.04756108]\n",
      " [-0.7189168  -0.9982114 ]\n",
      " [ 1.0019989  -0.25962105]\n",
      " [-0.03951053 -0.53585017]\n",
      " [ 0.8715444  -0.44617563]\n",
      " [-0.02620589  1.6385975 ]\n",
      " [-0.4435206  -1.4871048 ]], shape=(10, 2), dtype=float32) tf.Tensor(\n",
      "[ 0.75503004 -0.21832633  7.6747456   5.3869777   6.5747967   6.133599\n",
      "  5.506758    5.8919897  -1.7084911   8.131185  ], shape=(10,), dtype=float32)\n",
      "tf.Tensor(\n",
      "[[ 0.07098394  0.7610185 ]\n",
      " [-1.4937037   0.31498533]\n",
      " [ 0.49295455 -0.17755073]\n",
      " [-1.3144475  -0.28446528]\n",
      " [ 1.1292464   0.01913687]\n",
      " [-0.975937    0.2641378 ]\n",
      " [ 1.5799092  -1.6587117 ]\n",
      " [-0.48335934  1.1860058 ]\n",
      " [ 1.0200642  -1.1216661 ]\n",
      " [ 0.99716824 -1.6595705 ]], shape=(10, 2), dtype=float32) tf.Tensor(\n",
      "[ 3.9162815  -1.6573104   4.2962074   2.956503    6.713865    0.5664011\n",
      " 11.507958    0.34090543 10.768592   13.797123  ], shape=(10,), dtype=float32)\n",
      "tf.Tensor(\n",
      "[[-0.32963756 -0.17879893]\n",
      " [-0.28550628 -0.84229636]\n",
      " [-0.37928122  2.1201289 ]\n",
      " [-0.5276483  -1.6617805 ]\n",
      " [-1.1918455  -1.2413772 ]\n",
      " [-0.57559776  1.2606221 ]\n",
      " [-1.5968635   0.02389363]\n",
      " [ 1.0372789  -0.4735577 ]\n",
      " [-1.0861559  -1.4914737 ]\n",
      " [-1.8342255  -1.3676944 ]], shape=(10, 2), dtype=float32) tf.Tensor(\n",
      "[ 4.8872657  6.295317  -5.1979513  8.317087   4.6991477  0.8819771\n",
      " -0.5550711  7.603079   6.4729247  5.5238047], shape=(10,), dtype=float32)\n",
      "tf.Tensor(\n",
      "[[ 1.5990344   0.64385134]\n",
      " [ 0.8056459  -1.2994926 ]\n",
      " [-1.6464137  -1.0374994 ]\n",
      " [-1.1724107   0.47447208]\n",
      " [-1.4886305   0.46023262]\n",
      " [-0.05894518 -0.10483687]\n",
      " [ 0.9165028   1.2857692 ]\n",
      " [ 1.6441835  -1.1861233 ]\n",
      " [ 0.07984969 -0.28419986]\n",
      " [ 1.1077236  -1.4784268 ]], shape=(10, 2), dtype=float32) tf.Tensor(\n",
      "[ 6.759586    9.878051    3.7935574   2.750776   -1.6762196   4.6590962\n",
      "  0.23680973 13.057441    7.067713   11.400486  ], shape=(10,), dtype=float32)\n",
      "tf.Tensor(\n",
      "[[-0.56969523  0.49872625]\n",
      " [-0.38378784 -0.4521399 ]\n",
      " [ 0.44951433 -0.7830475 ]\n",
      " [-0.41200885  0.6241252 ]\n",
      " [-1.4051225  -0.2903889 ]\n",
      " [-0.486405    1.1614745 ]\n",
      " [-1.7682773   0.3015366 ]\n",
      " [-1.076666   -0.57757276]\n",
      " [ 0.31528765 -0.7456124 ]\n",
      " [ 0.6430355  -0.53011906]], shape=(10, 2), dtype=float32) tf.Tensor(\n",
      "[1.7773242  5.2496586  9.867434   1.3995328  1.6296213  0.2257545\n",
      " 0.03902397 5.149946   7.4552393  6.5853577 ], shape=(10,), dtype=float32)\n",
      "tf.Tensor(\n",
      "[[-0.4768679   0.26960528]\n",
      " [ 0.9019509  -0.8988528 ]\n",
      " [-1.2079364  -1.5522336 ]\n",
      " [-0.2849494  -0.2610241 ]\n",
      " [-0.50406235 -1.414449  ]\n",
      " [-0.34273642 -1.6794101 ]\n",
      " [ 0.52862704 -0.51703954]\n",
      " [ 0.26011676 -0.7794228 ]\n",
      " [ 2.2218266   0.9811566 ]\n",
      " [-0.9963279  -0.22630055]], shape=(10, 2), dtype=float32) tf.Tensor(\n",
      "[2.8983145 8.459014  7.026891  4.304131  9.026468  9.37273   7.8723483\n",
      " 7.3421316 6.2567124 3.0429304], shape=(10,), dtype=float32)\n",
      "tf.Tensor(\n",
      "[[-0.84757644  1.3860264 ]\n",
      " [ 0.8189015   0.18351427]\n",
      " [ 0.3941127   0.6117157 ]\n",
      " [-0.9885426   0.73488396]\n",
      " [-1.113041    0.34005198]\n",
      " [-0.14085214  0.59524643]\n",
      " [ 1.3783762  -0.2728713 ]\n",
      " [ 1.3645569  -1.2886747 ]\n",
      " [-1.6964512   0.11870074]\n",
      " [ 0.92520875 -1.7313801 ]], shape=(10, 2), dtype=float32) tf.Tensor(\n",
      "[-1.1449175   6.1107225   0.9110117   0.31778437  0.81719637  3.2743154\n",
      "  7.4367757  11.765144    0.63569546 12.462312  ], shape=(10,), dtype=float32)\n",
      "tf.Tensor(\n",
      "[[ 0.40653747 -0.03596346]\n",
      " [-0.2217145   0.50405586]\n",
      " [-1.0898601  -0.91904444]\n",
      " [-1.0808575   0.46571723]\n",
      " [-0.4687618   0.44204503]\n",
      " [-0.04375833  0.94704163]\n",
      " [ 0.04182794  0.02510107]\n",
      " [ 1.00544     1.6568993 ]\n",
      " [-0.1414499   0.07693157]\n",
      " [-0.72036743 -1.458167  ]], shape=(10, 2), dtype=float32) tf.Tensor(\n",
      "[ 4.041073    3.199571    5.7079563  -0.57797074  2.4115782  -0.47129393\n",
      "  3.7473166  -0.59386015  4.274938    8.946584  ], shape=(10,), dtype=float32)\n",
      "tf.Tensor(\n",
      "[[-0.6022885  -0.3882178 ]\n",
      " [ 0.6262018   0.6512881 ]\n",
      " [ 1.192785    0.5990242 ]\n",
      " [-0.23425119 -0.87086606]\n",
      " [ 0.42231092 -0.7012107 ]\n",
      " [-0.2503515  -0.45392936]\n",
      " [-0.7357626  -0.1889331 ]\n",
      " [-1.6378682  -0.7296077 ]\n",
      " [ 0.05451222 -1.0431894 ]\n",
      " [-0.97770983  0.51194793]], shape=(10, 2), dtype=float32) tf.Tensor(\n",
      "[4.065533  4.008437  3.0724192 7.172063  7.285798  4.6421328 3.3970141\n",
      " 4.188374  6.8038616 2.000371 ], shape=(10,), dtype=float32)\n",
      "tf.Tensor(\n",
      "[[ 0.99759865  0.61982524]\n",
      " [-1.1763185   0.33329242]\n",
      " [ 2.2374341  -0.7410188 ]\n",
      " [ 0.22119047  0.16397387]\n",
      " [ 0.9512891   0.38217255]\n",
      " [ 0.04730774 -0.59188753]\n",
      " [ 1.3875539  -1.7600806 ]\n",
      " [-0.91565824  0.5294865 ]\n",
      " [ 0.97414607  1.6481928 ]\n",
      " [ 2.0044527   0.18473475]], shape=(10, 2), dtype=float32) tf.Tensor(\n",
      "[ 3.627644   -0.15073204 12.534074    4.0439034   4.853264    7.067774\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      " 14.098777    0.1638473   0.06691381  7.3574424 ], shape=(10,), dtype=float32)\n",
      "tf.Tensor(\n",
      "[[ 0.81126904 -1.1031327 ]\n",
      " [ 0.5773093   0.52569664]\n",
      " [-2.5689397  -0.28584072]\n",
      " [-0.29423556  1.5898315 ]\n",
      " [ 1.1268957   0.1845486 ]\n",
      " [ 1.4647071  -0.39989224]\n",
      " [ 0.9653343  -0.6262987 ]\n",
      " [ 0.9070358  -0.7697269 ]\n",
      " [ 1.5318714   0.27064866]\n",
      " [ 0.9391578  -1.9667487 ]], shape=(10, 2), dtype=float32) tf.Tensor(\n",
      "[10.896067    2.937134    1.5807672  -0.21874225  5.876279    8.186303\n",
      "  8.1127615   8.3542185   6.0143247  12.638846  ], shape=(10,), dtype=float32)\n",
      "tf.Tensor(\n",
      "[[ 1.3963196  -1.8400693 ]\n",
      " [-0.10845938 -0.20753965]\n",
      " [-1.4031105  -0.05314368]\n",
      " [ 0.5519065   0.26290342]\n",
      " [-0.801027   -0.67163175]\n",
      " [ 0.25558716 -0.5031781 ]\n",
      " [ 0.35773808 -0.45481104]\n",
      " [-0.7326419  -0.77669924]\n",
      " [ 0.6297      1.558593  ]\n",
      " [ 1.9685175  -0.99267465]], shape=(10, 2), dtype=float32) tf.Tensor(\n",
      "[12.289181   4.5058174  2.6665316  5.46426    4.1114993  4.9977365\n",
      "  7.4312325  5.9680605  1.509115   9.973228 ], shape=(10,), dtype=float32)\n",
      "tf.Tensor(\n",
      "[[-0.974126    0.07843796]\n",
      " [ 0.8694007  -0.0284719 ]\n",
      " [ 1.8307135   0.7182965 ]\n",
      " [-0.8162247  -0.53350884]\n",
      " [-0.88225037  2.4837039 ]\n",
      " [ 0.11627074 -0.48078337]\n",
      " [ 0.0577732  -1.5226653 ]\n",
      " [-0.45187107  0.04538204]\n",
      " [-0.04853089 -0.01137651]\n",
      " [-0.814584    0.25849283]], shape=(10, 2), dtype=float32) tf.Tensor(\n",
      "[ 2.2999732   4.524429    4.606958    5.143648   -4.4870253   6.3199897\n",
      "  8.781733    2.5196602   3.3419724  -0.01763904], shape=(10,), dtype=float32)\n",
      "tf.Tensor(\n",
      "[[ 1.7763275   0.324963  ]\n",
      " [-0.53078884  0.39620233]\n",
      " [ 0.07702319  0.30157387]\n",
      " [-0.06942746  1.1124932 ]\n",
      " [ 1.2030952  -1.3394417 ]\n",
      " [-0.08323904 -1.326805  ]\n",
      " [-3.400304   -0.4230187 ]\n",
      " [ 0.0856067   1.2167511 ]\n",
      " [ 0.9556264   0.63354564]\n",
      " [-0.15722927  0.6834282 ]], shape=(10, 2), dtype=float32) tf.Tensor(\n",
      "[ 6.9500284   0.1459961   2.4094944   0.5888004  13.612989    8.473561\n",
      "  0.70477486 -0.448775    3.4984396   2.4094498 ], shape=(10,), dtype=float32)\n",
      "tf.Tensor(\n",
      "[[-1.5132113  -0.7650717 ]\n",
      " [ 1.0886668  -0.83053696]\n",
      " [-0.3230481  -1.2783158 ]\n",
      " [ 0.49415606  0.4021702 ]\n",
      " [ 1.8844097  -0.8121302 ]\n",
      " [ 0.08146157  0.5599372 ]\n",
      " [-0.61845464  0.09541591]\n",
      " [-1.4076341   0.16520266]\n",
      " [ 0.6835887   1.7787839 ]\n",
      " [ 0.7812093  -0.28226343]], shape=(10, 2), dtype=float32) tf.Tensor(\n",
      "[ 3.075387    8.548598    8.343064    4.4068785  10.516168    3.3090928\n",
      "  0.23822927 -0.68220043  0.9144982   5.8291497 ], shape=(10,), dtype=float32)\n",
      "tf.Tensor(\n",
      "[[ 0.9140777   1.8814276 ]\n",
      " [-1.5299873  -0.8810043 ]\n",
      " [ 0.73319215 -0.01334965]\n",
      " [-1.5521306  -0.0616357 ]\n",
      " [-2.010108   -1.0458044 ]\n",
      " [ 0.08163139  0.28333881]\n",
      " [-0.3160373  -0.9493622 ]\n",
      " [-1.4266262  -0.74537617]\n",
      " [-0.20149061 -1.8654685 ]\n",
      " [-0.7919837  -1.3230078 ]], shape=(10, 2), dtype=float32) tf.Tensor(\n",
      "[-1.4785466  4.9878373  5.1867437  2.2078204  3.662821   4.779892\n",
      "  5.9180193  3.3623319  9.678492   7.29512  ], shape=(10,), dtype=float32)\n",
      "tf.Tensor(\n",
      "[[-0.2858176   1.6017777 ]\n",
      " [-0.7339322   0.417993  ]\n",
      " [-1.7430782  -1.5595858 ]\n",
      " [-1.1246336   1.521625  ]\n",
      " [-0.6474844   1.7347523 ]\n",
      " [-0.9394848   1.1046553 ]\n",
      " [-0.19029601 -0.3421864 ]\n",
      " [ 0.01316721 -1.1305285 ]\n",
      " [-0.04158554  0.31263125]\n",
      " [-0.3171111  -1.3395845 ]], shape=(10, 2), dtype=float32) tf.Tensor(\n",
      "[-1.1287806  2.4007108  6.152313  -2.588324  -2.7407975 -1.7205592\n",
      "  3.173342   6.882839   3.5082302  8.067121 ], shape=(10,), dtype=float32)\n",
      "tf.Tensor(\n",
      "[[ 0.33667004 -0.6038111 ]\n",
      " [ 1.1092451   1.2537414 ]\n",
      " [ 1.4486678   0.39849612]\n",
      " [ 0.8812174   0.79122436]\n",
      " [ 0.59988314  0.40171292]\n",
      " [-0.63932043  1.398064  ]\n",
      " [-1.1414961  -0.18251698]\n",
      " [-0.16036168 -0.27391443]\n",
      " [ 0.06779578 -1.8529286 ]\n",
      " [-0.41152278  0.21730867]], shape=(10, 2), dtype=float32) tf.Tensor(\n",
      "[ 7.7912545  3.366486   6.369839   4.207931   2.843376  -2.526204\n",
      "  1.9162115  4.461914  10.679356   2.3089168], shape=(10,), dtype=float32)\n",
      "tf.Tensor(\n",
      "[[-0.6537401   0.57584137]\n",
      " [-0.2761731   0.73968154]\n",
      " [ 0.04050217  0.45967984]\n",
      " [-2.5537348   1.104506  ]\n",
      " [-1.4039648  -0.3564665 ]\n",
      " [-0.3815629  -1.9025482 ]\n",
      " [-0.3193633  -2.0648222 ]\n",
      " [ 1.4901121  -0.08454692]\n",
      " [ 0.5504274  -0.6276863 ]\n",
      " [ 0.0256011  -1.622916  ]], shape=(10, 2), dtype=float32) tf.Tensor(\n",
      "[ 0.12762052  1.9892478   2.2945917  -4.8338137   3.7480736   8.991155\n",
      " 12.804968    5.7595935   7.390721    9.922559  ], shape=(10,), dtype=float32)\n",
      "tf.Tensor(\n",
      "[[-1.1811863  -0.14676496]\n",
      " [-1.2134874   0.10888284]\n",
      " [-1.2168086   1.9507785 ]\n",
      " [-0.42530864 -1.125292  ]\n",
      " [-1.8162862  -0.13727318]\n",
      " [-0.07545798  0.65859395]\n",
      " [ 1.6715547  -1.2533629 ]\n",
      " [ 1.618836   -1.4991187 ]\n",
      " [ 0.8671102  -0.21159874]\n",
      " [-0.14325163  0.851248  ]], shape=(10, 2), dtype=float32) tf.Tensor(\n",
      "[ 1.6541638e+00  1.5947827e+00 -6.5513034e+00  6.2535391e+00\n",
      "  2.1571116e+00  3.8947999e-01  1.2167670e+01  1.2201895e+01\n",
      "  6.5340199e+00  7.6137781e-03], shape=(10,), dtype=float32)\n",
      "tf.Tensor(\n",
      "[[-1.5095558  -0.12345704]\n",
      " [ 0.16441996  1.8888191 ]\n",
      " [ 1.2265618   0.92302316]\n",
      " [ 0.38169104  0.50555414]\n",
      " [ 0.14971429 -0.84994227]\n",
      " [ 0.26478344 -0.8226756 ]\n",
      " [-0.37932852  0.2654286 ]\n",
      " [ 0.93175393 -0.41261995]\n",
      " [ 0.5303645   0.52615535]\n",
      " [-0.4213379   0.8962226 ]], shape=(10, 2), dtype=float32) tf.Tensor(\n",
      "[ 2.6543112  -0.31092596  3.9018621   1.8823347   5.3116918   6.6793203\n",
      "  3.0502043   7.6321883   1.7091739  -0.13323951], shape=(10,), dtype=float32)\n",
      "tf.Tensor(\n",
      "[[-2.1438968   0.90833473]\n",
      " [-1.4492397  -0.82801014]\n",
      " [-0.85571146 -0.33494526]\n",
      " [-0.26058063  0.91507924]\n",
      " [ 0.17657024  0.00569523]\n",
      " [ 0.22212906  0.5772021 ]\n",
      " [-0.62285864  0.5551178 ]\n",
      " [ 0.7764615  -0.7040234 ]\n",
      " [ 1.1227814   1.7154869 ]\n",
      " [-0.3300449  -0.06838498]], shape=(10, 2), dtype=float32) tf.Tensor(\n",
      "[-2.2024148   4.9496346   2.4559665  -0.47479427  3.6476102   3.817206\n",
      "  2.1388412   8.632066    2.5312228   5.3920965 ], shape=(10,), dtype=float32)\n",
      "tf.Tensor(\n",
      "[[ 1.0772187   0.46054882]\n",
      " [ 0.6228134  -0.7205731 ]\n",
      " [ 0.18880916  0.50539064]\n",
      " [-0.253065    1.9357624 ]\n",
      " [-0.2697137  -0.31189337]\n",
      " [-0.30064046  0.62967104]\n",
      " [-0.5794012  -0.20186785]\n",
      " [ 0.9976721   2.9673412 ]\n",
      " [-0.8880355  -0.27082446]\n",
      " [-1.0172927   0.5095796 ]], shape=(10, 2), dtype=float32) tf.Tensor(\n",
      "[ 5.795924    8.576421    2.2676206  -2.6082168   5.6247888  -0.76632094\n",
      "  4.909712   -5.047277    4.268156    0.33613342], shape=(10,), dtype=float32)\n",
      "tf.Tensor(\n",
      "[[-1.4624482  -1.036422  ]\n",
      " [-0.7529743  -1.1309793 ]\n",
      " [ 1.1528434   0.1940882 ]\n",
      " [-0.8243565   0.3926271 ]\n",
      " [-0.7024341  -3.900228  ]\n",
      " [-1.2001239  -1.0502886 ]\n",
      " [ 0.15227307 -0.47355616]\n",
      " [-1.9881697  -1.7386874 ]\n",
      " [ 1.4111774   1.0326469 ]\n",
      " [-0.04222883 -1.0714781 ]], shape=(10, 2), dtype=float32) tf.Tensor(\n",
      "[ 3.418939   7.556559   6.962254   2.0293677 16.908127   4.3436556\n",
      "  5.687203   5.856466   4.1823564  6.2855043], shape=(10,), dtype=float32)\n",
      "tf.Tensor(\n",
      "[[ 0.59205824  1.8203834 ]\n",
      " [ 2.294695    0.8080571 ]\n",
      " [ 1.9793563   1.4378083 ]\n",
      " [-1.2193481   1.957104  ]\n",
      " [ 0.2773638  -1.5512625 ]\n",
      " [ 0.5928072   1.005351  ]\n",
      " [-1.5683045  -0.21182683]\n",
      " [ 0.76059735 -0.9564342 ]\n",
      " [ 1.2592807  -0.9440555 ]\n",
      " [ 0.23251614 -1.2786493 ]], shape=(10, 2), dtype=float32) tf.Tensor(\n",
      "[-1.9430242  6.203505   3.376371  -3.1241207  8.935476   1.0405512\n",
      "  1.1752563  9.5246315 10.106037   8.620813 ], shape=(10,), dtype=float32)\n",
      "tf.Tensor(\n",
      "[[ 0.44889104  1.9016367 ]\n",
      " [ 0.57414025 -0.16319355]\n",
      " [ 1.6965301  -2.0905883 ]\n",
      " [ 1.708086    1.9649585 ]\n",
      " [-0.90939546 -0.17601971]\n",
      " [ 0.11441451  0.46261954]\n",
      " [-0.20679553 -1.5855548 ]\n",
      " [-0.7271325  -0.077973  ]\n",
      " [-0.41288725 -0.82179844]\n",
      " [ 0.88431305  2.0284922 ]], shape=(10, 2), dtype=float32) tf.Tensor(\n",
      "[-1.5102898  7.1798773 17.59411    1.3757063  3.374863   1.0976952\n",
      "  9.660544   1.6047623  5.554015  -1.1189109], shape=(10,), dtype=float32)\n",
      "tf.Tensor(\n",
      "[[ 0.32278627 -0.07103787]\n",
      " [ 0.40712386  0.4700394 ]\n",
      " [-1.0457474   0.3940467 ]\n",
      " [ 0.0321387   0.8131376 ]\n",
      " [-0.3222173   0.7923851 ]\n",
      " [ 0.1667241  -0.42561665]\n",
      " [ 0.65040404 -0.8194712 ]\n",
      " [ 1.0256138  -0.86471015]\n",
      " [ 2.0650704   1.3699709 ]\n",
      " [ 0.00601456  0.21963733]], shape=(10, 2), dtype=float32) tf.Tensor(\n",
      "[ 4.64837     2.2129118   1.1819286   2.457588   -0.04073352  5.0423055\n",
      "  6.832121    8.261942    4.5212603   4.6476707 ], shape=(10,), dtype=float32)\n",
      "tf.Tensor(\n",
      "[[-0.6431424   0.30570108]\n",
      " [ 0.3627881   1.3261995 ]\n",
      " [-0.6644802  -0.967041  ]\n",
      " [ 0.42530754  0.7718239 ]\n",
      " [-0.62290865 -1.2792617 ]\n",
      " [ 0.7377149  -0.1766686 ]\n",
      " [ 0.27299103 -0.57951295]\n",
      " [-2.5791535   0.18834499]\n",
      " [ 0.9439868  -0.23660445]\n",
      " [ 0.03406807  1.8634276 ]], shape=(10, 2), dtype=float32) tf.Tensor(\n",
      "[ 2.4119844 -0.1584841  6.4484863  2.3020623  6.087915   5.0087466\n",
      "  5.7474365 -3.3931155  7.044909  -1.9301413], shape=(10,), dtype=float32)\n",
      "tf.Tensor(\n",
      "[[-1.4243594  -1.2237453 ]\n",
      " [-1.312967    1.3322909 ]\n",
      " [ 1.3690708   2.6310787 ]\n",
      " [ 0.4273383  -1.628196  ]\n",
      " [-0.1753863  -0.33050695]\n",
      " [ 1.442008    0.01956155]\n",
      " [ 2.428667    1.3097616 ]\n",
      " [ 0.7031497   0.9665668 ]\n",
      " [ 1.0585229   1.146845  ]\n",
      " [-0.37335706 -1.2542229 ]], shape=(10, 2), dtype=float32) tf.Tensor(\n",
      "[ 3.6454635 -1.9505727 -2.243018   9.849174   5.4114146  7.501045\n",
      "  4.3447943  2.332684   2.4663837  7.776327 ], shape=(10,), dtype=float32)\n",
      "tf.Tensor(\n",
      "[[ 0.30097038 -1.0937511 ]\n",
      " [ 2.2061384   1.9755276 ]\n",
      " [-0.76961964 -0.48978665]\n",
      " [ 1.0485682   0.55610555]\n",
      " [ 0.9943435   2.3410485 ]\n",
      " [ 1.5938153   0.47450402]\n",
      " [ 1.1933632  -2.420236  ]\n",
      " [ 0.02336439  0.55349445]\n",
      " [-0.4031843   0.35736504]\n",
      " [-0.39169535 -0.9737471 ]], shape=(10, 2), dtype=float32) tf.Tensor(\n",
      "[ 6.0670333   1.649234    4.8490286   2.554719   -1.0624645   8.917374\n",
      " 13.873726    0.50668776  2.8957512   5.3858333 ], shape=(10,), dtype=float32)\n",
      "tf.Tensor(\n",
      "[[ 0.70213753  1.2244786 ]\n",
      " [-0.78075004  0.26034772]\n",
      " [-0.3405282   0.44820157]\n",
      " [ 1.507314    0.03898733]\n",
      " [ 0.77432925 -0.5916473 ]\n",
      " [-0.4000893   0.6665461 ]\n",
      " [ 0.9310079  -0.49437073]\n",
      " [ 1.8015202  -1.1733662 ]\n",
      " [-0.57742107  0.4513238 ]\n",
      " [ 0.5192132   1.5427896 ]], shape=(10, 2), dtype=float32) tf.Tensor(\n",
      "[ 1.2248855   1.1159179   0.8367723   5.365486    6.0886784   0.16417992\n",
      "  8.022192   12.380428    0.92572    -1.2146033 ], shape=(10,), dtype=float32)\n",
      "tf.Tensor(\n",
      "[[ 1.8799373  -0.56806535]\n",
      " [ 0.22233455  0.8677957 ]\n",
      " [-1.1533779  -1.8434207 ]\n",
      " [-1.0861868   0.2507045 ]\n",
      " [-0.58125395 -0.06425858]\n",
      " [-0.72285235 -1.3156234 ]\n",
      " [-1.317518    0.33482668]\n",
      " [-0.7614999  -0.49757686]\n",
      " [ 1.4305346  -0.9118106 ]\n",
      " [-0.46201515 -1.8794653 ]], shape=(10, 2), dtype=float32) tf.Tensor(\n",
      "[10.853483   2.69873    8.693282   2.806367   1.7545884  5.865502\n",
      " -0.7093084  3.460507   8.655436   9.64724  ], shape=(10,), dtype=float32)\n",
      "tf.Tensor(\n",
      "[[-0.7106154   0.21024863]\n",
      " [ 0.02288705  1.9464152 ]\n",
      " [ 0.34579995  2.2538476 ]\n",
      " [ 0.23431015 -0.24877974]\n",
      " [-0.20010164  1.5044369 ]\n",
      " [-0.04078678 -0.71474636]\n",
      " [-0.25924003 -0.20501086]\n",
      " [ 1.131658    0.24582095]\n",
      " [-0.3059841  -0.5449899 ]\n",
      " [ 0.8142854   1.8811672 ]], shape=(10, 2), dtype=float32) tf.Tensor(\n",
      "[ 2.4163747  -1.946066   -2.0591874   5.257134   -0.26777208  6.211419\n",
      "  4.104768    5.0835934   5.6943483   0.34852844], shape=(10,), dtype=float32)\n",
      "tf.Tensor(\n",
      "[[-0.80590016 -0.4081868 ]\n",
      " [ 1.4614545  -0.5512109 ]\n",
      " [-0.01433476  0.654636  ]\n",
      " [-0.7321184   0.15190215]\n",
      " [ 0.21144152 -0.13106778]\n",
      " [-0.62666327  0.47343653]\n",
      " [-0.03378433 -0.7171419 ]\n",
      " [-0.22582705 -0.67038786]\n",
      " [-0.66172     1.1629282 ]\n",
      " [ 0.05911122  0.0663214 ]], shape=(10, 2), dtype=float32) tf.Tensor(\n",
      "[ 4.244033   7.30906    2.659626   2.0216026  5.32583    1.4907879\n",
      "  8.345179   5.775927  -0.5223541  4.8593087], shape=(10,), dtype=float32)\n",
      "tf.Tensor(\n",
      "[[ 0.51264     0.93072695]\n",
      " [-0.58443874 -0.6625883 ]\n",
      " [ 1.7588545   0.3621676 ]\n",
      " [ 1.742548   -0.29445723]\n",
      " [-1.5856117  -0.49760446]\n",
      " [-0.5193889  -0.62683356]\n",
      " [ 0.9060243   0.1516876 ]\n",
      " [-0.2271039  -0.71199137]\n",
      " [-1.1187224  -0.71896416]\n",
      " [ 1.1817737  -0.70193636]], shape=(10, 2), dtype=float32) tf.Tensor(\n",
      "[0.96845686 6.832988   7.7375097  8.32001    3.073807   6.22901\n",
      " 7.7293997  5.000404   5.5185804  9.653906  ], shape=(10,), dtype=float32)\n",
      "tf.Tensor(\n",
      "[[ 1.0674484  -0.05468632]\n",
      " [ 1.3732026  -0.77976674]\n",
      " [-0.8885737   0.7243225 ]\n",
      " [ 1.1335056   1.609882  ]\n",
      " [-0.999914   -0.2665146 ]\n",
      " [ 0.67212087 -0.34484378]\n",
      " [ 1.4691746   1.0663928 ]\n",
      " [-0.38171554 -1.6156105 ]\n",
      " [ 0.22360267 -0.06787248]\n",
      " [-0.37660912  0.74545556]], shape=(10, 2), dtype=float32) tf.Tensor(\n",
      "[ 5.411916   8.658504  -0.99053    1.2828501  1.9678512  6.4493647\n",
      "  2.212835   9.810351   5.921006   0.8505681], shape=(10,), dtype=float32)\n",
      "tf.Tensor(\n",
      "[[-0.39417544 -0.3488586 ]\n",
      " [-1.5032641   0.0950891 ]\n",
      " [-0.6724212   0.07131099]\n",
      " [ 1.0686466   0.8718358 ]\n",
      " [ 0.47587737  1.7895637 ]\n",
      " [ 1.4198465  -1.32848   ]\n",
      " [-2.3349283   1.197794  ]\n",
      " [-0.13921466  1.9747077 ]\n",
      " [-1.4961314  -0.3851347 ]\n",
      " [-0.2341401   0.24675089]], shape=(10, 2), dtype=float32) tf.Tensor(\n",
      "[ 5.825053   0.8004134  3.707688   3.8788245 -3.1269448 10.066331\n",
      " -3.4806113 -2.8947723  2.4434376  4.0341125], shape=(10,), dtype=float32)\n",
      "tf.Tensor(\n",
      "[[-7.3514442e-04 -2.1340869e-01]\n",
      " [-5.6640212e-03  6.4703387e-01]\n",
      " [-1.4083797e-01 -5.4061830e-02]\n",
      " [-1.0492207e+00  4.7151417e-01]\n",
      " [-1.4705442e+00  1.5329176e+00]\n",
      " [-1.0150362e+00 -2.1317017e-01]\n",
      " [ 9.1059881e-01  1.5091169e+00]\n",
      " [ 7.8489095e-01  4.9815506e-01]\n",
      " [ 1.8545880e+00  5.4263240e-01]\n",
      " [-9.8788589e-01 -9.5788282e-01]], shape=(10, 2), dtype=float32) tf.Tensor(\n",
      "[ 4.6295094  -0.10601354  3.9864497   1.2995498  -3.8670042   3.1382785\n",
      "  1.2799714   2.9423158   6.2439194   3.84486   ], shape=(10,), dtype=float32)\n",
      "tf.Tensor(\n",
      "[[-1.8689873   0.25047675]\n",
      " [-0.05428683 -0.20788607]\n",
      " [ 2.0845141  -0.83799845]\n",
      " [ 0.01545457  1.2721788 ]\n",
      " [-0.98985386 -1.1163808 ]\n",
      " [-1.1808217   2.25053   ]\n",
      " [ 1.4279157   1.428474  ]\n",
      " [-0.7235001   0.39532697]\n",
      " [ 0.01325469  0.26815376]\n",
      " [-1.0712914   0.04745918]], shape=(10, 2), dtype=float32) tf.Tensor(\n",
      "[ 1.7555418   4.0691423  11.951848   -0.60508245  5.1611085  -7.084483\n",
      "  2.3646846   1.0547277   4.5435863   1.256057  ], shape=(10,), dtype=float32)\n",
      "tf.Tensor(\n",
      "[[ 0.26978728 -0.4764915 ]\n",
      " [ 0.4055703   0.5269658 ]\n",
      " [ 1.1969404   0.77451915]\n",
      " [ 0.5331936   0.31058115]\n",
      " [ 0.92313963  0.08865912]\n",
      " [ 0.8905553  -0.2435776 ]\n",
      " [-0.93434626  0.27864718]\n",
      " [ 0.36108035 -0.6461117 ]\n",
      " [ 0.25944588  0.8775805 ]\n",
      " [-0.19533616  0.02797231]], shape=(10, 2), dtype=float32) tf.Tensor(\n",
      "[7.252826  2.391817  3.8058708 3.4559436 4.6925144 6.6883717 2.361701\n",
      " 8.696     1.2065833 3.5883043], shape=(10,), dtype=float32)\n",
      "tf.Tensor(\n",
      "[[ 1.2504979   1.2406459 ]\n",
      " [-0.4885262   0.26471752]\n",
      " [ 0.94158506 -0.27798152]\n",
      " [ 0.08475741 -0.80112076]\n",
      " [-0.3997115  -0.6276089 ]\n",
      " [-0.3336584  -0.4706696 ]\n",
      " [-0.50945675  2.9595017 ]\n",
      " [-1.4335606   0.35095936]\n",
      " [-0.9907712  -1.8758119 ]\n",
      " [ 2.733584    0.8105979 ]], shape=(10, 2), dtype=float32) tf.Tensor(\n",
      "[ 2.1537633  2.1992252  6.903285   7.407846   6.038605   3.818668\n",
      " -6.7930155 -1.4988781 10.359206   6.6883116], shape=(10,), dtype=float32)\n",
      "tf.Tensor(\n",
      "[[-0.91029817  1.4760375 ]\n",
      " [-1.4012841  -0.23092209]\n",
      " [ 1.7304804  -0.21517166]\n",
      " [-0.7208132  -0.67267346]\n",
      " [ 1.548224    1.655275  ]\n",
      " [ 0.22687432  0.5049294 ]\n",
      " [-0.92536324  1.8204731 ]\n",
      " [-2.6976378   0.15465914]\n",
      " [-1.6135027  -0.22033638]\n",
      " [ 0.8643945   1.1900909 ]], shape=(10, 2), dtype=float32) tf.Tensor(\n",
      "[-3.2917268  1.0539912  6.933145   5.9386935  1.1736839  3.0390553\n",
      " -2.2796922 -2.9298272  2.953506   2.6183386], shape=(10,), dtype=float32)\n",
      "tf.Tensor(\n",
      "[[-1.1094347   0.5843746 ]\n",
      " [-1.3263103   0.04493076]\n",
      " [ 0.44423214 -2.141439  ]\n",
      " [ 1.9679552  -0.30265474]\n",
      " [-0.02442604  0.33555165]\n",
      " [ 1.1558957   0.84229165]\n",
      " [ 0.8313388   1.4003894 ]\n",
      " [-0.94602394  0.6249829 ]\n",
      " [ 0.54840237  1.1846598 ]\n",
      " [-0.17580833 -2.9912283 ]], shape=(10, 2), dtype=float32) tf.Tensor(\n",
      "[ 0.532108    1.0387012  11.058697    8.994289    2.26402     5.523275\n",
      "  0.54188734  1.3244073   2.7496815  13.911055  ], shape=(10,), dtype=float32)\n",
      "tf.Tensor(\n",
      "[[ 0.12856477 -1.0995686 ]\n",
      " [ 2.116892    0.9061542 ]\n",
      " [-0.6645203   0.0858366 ]\n",
      " [-0.5545924  -0.39731938]\n",
      " [-1.3878844  -0.16576567]\n",
      " [-0.09523348 -1.1599945 ]\n",
      " [-1.2696091  -0.7981143 ]\n",
      " [-0.04621366  1.8748553 ]\n",
      " [ 0.7591135  -1.2584983 ]\n",
      " [-0.6577461  -0.0998065 ]], shape=(10, 2), dtype=float32) tf.Tensor(\n",
      "[ 7.8726225  6.091512   2.0670028  5.626979   3.2897792  8.6007185\n",
      "  3.1097233 -2.8109226 10.424001   4.4661846], shape=(10,), dtype=float32)\n",
      "tf.Tensor(\n",
      "[[ 1.0245186  -0.9939451 ]\n",
      " [ 0.39329565  0.6403267 ]\n",
      " [ 0.2381053   1.0696553 ]\n",
      " [ 2.2698057  -0.51266545]\n",
      " [-1.2176622   0.5199796 ]\n",
      " [-0.8640965   0.12678137]\n",
      " [-0.2878946  -0.30255896]\n",
      " [ 1.3619236  -0.19841754]\n",
      " [-2.3668709  -1.9528912 ]\n",
      " [ 0.10414395  0.8546924 ]], shape=(10, 2), dtype=float32) tf.Tensor(\n",
      "[ 8.480028   4.173512  -0.5181812  9.135073  -1.8770379  0.7502656\n",
      "  3.3395634  7.618667   5.086837   1.7932248], shape=(10,), dtype=float32)\n",
      "tf.Tensor(\n",
      "[[-2.4631922  -1.4402764 ]\n",
      " [ 1.7453665   0.83827335]\n",
      " [-1.1317152   0.83818245]\n",
      " [-1.0643916   1.3506627 ]\n",
      " [ 0.13515638 -0.10488329]\n",
      " [-0.41422     0.34663308]\n",
      " [-0.04706987 -0.3783937 ]\n",
      " [ 0.16850665  0.2824046 ]\n",
      " [-0.24121915 -1.9447576 ]\n",
      " [-1.0675095  -0.9956654 ]], shape=(10, 2), dtype=float32) tf.Tensor(\n",
      "[ 4.7560887   5.3257923  -0.45158577 -2.6235485   4.9682946   2.7459564\n",
      "  6.321348    4.787715   10.938058    7.3855176 ], shape=(10,), dtype=float32)\n",
      "tf.Tensor(\n",
      "[[ 0.11639426  0.02368227]\n",
      " [-1.6557862  -1.2890785 ]\n",
      " [-1.7958407  -0.3709615 ]\n",
      " [-0.15057895  1.1437856 ]\n",
      " [-1.620541    0.00735186]\n",
      " [-0.52179396 -0.05929884]\n",
      " [-0.4612119  -0.13253714]\n",
      " [ 0.21292357 -0.6323347 ]\n",
      " [-0.68528944 -0.70363444]\n",
      " [ 0.8014924  -0.38574454]], shape=(10, 2), dtype=float32) tf.Tensor(\n",
      "[3.5180602  5.425523   3.348889   0.42102033 1.3603055  2.5931134\n",
      " 2.4845324  5.988856   3.8879888  6.353596  ], shape=(10,), dtype=float32)\n",
      "tf.Tensor(\n",
      "[[-0.3431347  -1.1139243 ]\n",
      " [-0.453978    0.03257266]\n",
      " [-1.8294129  -0.09983701]\n",
      " [ 0.17778733  0.9901183 ]\n",
      " [ 0.6286419  -0.23994423]\n",
      " [ 0.89158314  1.4421545 ]\n",
      " [ 1.0909064   0.00514202]\n",
      " [ 1.0275049  -0.14420114]\n",
      " [ 0.10484169  1.8370947 ]\n",
      " [ 1.1772681  -0.19845495]], shape=(10, 2), dtype=float32) tf.Tensor(\n",
      "[ 7.932953    3.6022387   1.8009562   0.58323663  5.5823193   1.174964\n",
      "  5.395773    6.826695   -1.6700362   7.075457  ], shape=(10,), dtype=float32)\n",
      "tf.Tensor(\n",
      "[[ 1.0304571  -0.82709986]\n",
      " [ 1.1324881  -0.18175246]\n",
      " [-0.5431582   0.8448152 ]\n",
      " [-1.702759   -0.22307268]\n",
      " [-0.9561129  -0.38803178]\n",
      " [ 0.22089478  0.05608762]\n",
      " [-0.31485283 -0.22681732]\n",
      " [-1.5539534  -3.1494315 ]\n",
      " [-0.08724435 -0.3961873 ]\n",
      " [ 0.5202222   0.79638433]], shape=(10, 2), dtype=float32) tf.Tensor(\n",
      "[ 9.761526    6.519126   -0.19944742  1.3901917   4.1745515   4.607354\n",
      "  3.537447   12.549763    5.930127    1.8204672 ], shape=(10,), dtype=float32)\n",
      "tf.Tensor(\n",
      "[[-0.1354241   1.3939023 ]\n",
      " [ 1.6182315   1.64689   ]\n",
      " [ 0.7113997  -0.06738677]\n",
      " [-0.62089604  0.7633887 ]\n",
      " [-0.7408426  -0.45511773]\n",
      " [ 2.2468793  -0.2437138 ]\n",
      " [-0.23049952  2.593389  ]\n",
      " [-0.64990747  0.77803826]\n",
      " [ 0.6496197  -0.07578636]\n",
      " [ 0.6336132   0.49486622]], shape=(10, 2), dtype=float32) tf.Tensor(\n",
      "[ 2.3303876  1.1597136  5.7534075  0.7153472  5.4128804 11.1503315\n",
      " -6.4288144  2.4087207  7.1130896  3.8561444], shape=(10,), dtype=float32)\n",
      "tf.Tensor(\n",
      "[[-0.16379818  0.6754206 ]\n",
      " [-0.6640142  -0.02079428]\n",
      " [-0.9205211  -0.6835475 ]\n",
      " [-0.06579272  1.8942546 ]\n",
      " [ 0.92957896  0.71189016]\n",
      " [ 0.9890804  -0.92470837]\n",
      " [-0.28512093 -1.9153577 ]\n",
      " [-0.28031796  0.706168  ]\n",
      " [ 1.1136339   0.1675277 ]\n",
      " [ 1.7458189   1.0095315 ]], shape=(10, 2), dtype=float32) tf.Tensor(\n",
      "[ 1.4151576   0.93459034  4.1051383  -2.3602748   2.501995    9.086072\n",
      "  9.924981    0.9600906   6.5760565   4.3405013 ], shape=(10,), dtype=float32)\n",
      "tf.Tensor(\n",
      "[[ 1.3164148   0.30988255]\n",
      " [-1.2411069  -0.52834344]\n",
      " [-0.85445917 -0.12010897]\n",
      " [ 0.04793736  1.6074983 ]\n",
      " [-0.24679796  0.13688745]\n",
      " [-0.15080471  1.4290465 ]\n",
      " [-1.1949245  -0.15557927]\n",
      " [-1.180748    1.2103616 ]\n",
      " [-0.51701164 -0.633119  ]\n",
      " [ 1.6502571   0.09913642]], shape=(10, 2), dtype=float32) tf.Tensor(\n",
      "[ 5.854021   3.4592228  2.9881687 -1.1388019  4.211618  -2.144668\n",
      "  1.7982142 -2.8201733  6.320189   6.4683065], shape=(10,), dtype=float32)\n",
      "tf.Tensor(\n",
      "[[ 4.1796160e-01  8.3967859e-01]\n",
      " [-1.5947027e+00  3.3269206e-01]\n",
      " [-1.2030611e+00 -1.0684464e+00]\n",
      " [ 8.1316642e-03 -1.4654911e-01]\n",
      " [ 2.0830888e-01  1.1189134e+00]\n",
      " [-9.6892756e-01  5.5563873e-01]\n",
      " [ 2.0667748e+00 -6.9138145e-01]\n",
      " [-6.0653413e-04  1.2794524e-01]\n",
      " [ 4.1106543e-01  8.0241347e-03]\n",
      " [ 1.4496933e+00  1.2477669e+00]], shape=(10, 2), dtype=float32) tf.Tensor(\n",
      "[ 5.229599    0.7713938   5.3808756   4.8208084   2.0877314  -0.12552312\n",
      " 11.800975    5.63427     3.9417763   2.7132363 ], shape=(10,), dtype=float32)\n",
      "tf.Tensor(\n",
      "[[-0.4212615   0.10399342]\n",
      " [ 0.26623273  0.31067252]\n",
      " [-0.81898296  0.34400854]\n",
      " [ 2.4605725  -0.72416246]\n",
      " [-0.94258606 -1.0512005 ]\n",
      " [ 0.3822786   0.32609317]\n",
      " [-1.2279202  -0.04973411]\n",
      " [-1.7088602  -1.3913332 ]\n",
      " [-0.8542003   0.5068192 ]\n",
      " [ 0.42144874  1.9394826 ]], shape=(10, 2), dtype=float32) tf.Tensor(\n",
      "[ 3.82995     3.6131506   1.0276377  12.018205    7.236496    2.9449897\n",
      "  2.657848    6.2084746   0.30770078 -1.9378746 ], shape=(10,), dtype=float32)\n",
      "tf.Tensor(\n",
      "[[ 0.66502285 -0.65865856]\n",
      " [-1.5039442  -0.75074476]\n",
      " [ 0.71006495 -1.2367407 ]\n",
      " [-0.67567706 -0.39146823]\n",
      " [ 0.28485188 -0.36460063]\n",
      " [ 0.19920653  0.17553405]\n",
      " [-0.04802846  0.27272698]\n",
      " [ 0.86119854 -0.30996424]\n",
      " [ 0.07959372  0.39390823]\n",
      " [-0.93303514 -0.9684094 ]], shape=(10, 2), dtype=float32) tf.Tensor(\n",
      "[8.422046  4.1867743 9.570805  4.941053  6.439883  4.7600484 3.4664707\n",
      " 6.198015  3.2400541 6.2032743], shape=(10,), dtype=float32)\n",
      "tf.Tensor(\n",
      "[[-2.4803379   0.34678024]\n",
      " [-0.4586887  -1.8021817 ]\n",
      " [ 0.24893108 -0.22969042]\n",
      " [ 0.9766367   2.0851376 ]\n",
      " [ 1.6354457  -0.04374673]\n",
      " [-0.27194     1.0143782 ]\n",
      " [ 0.3128171  -0.10908067]\n",
      " [ 1.4960473  -0.9127604 ]\n",
      " [-1.0288805  -0.6840115 ]\n",
      " [ 0.78944945  0.19292434]], shape=(10, 2), dtype=float32) tf.Tensor(\n",
      "[-1.3985043   9.141476    7.1201067   0.00961024  8.686216    0.71842515\n",
      "  5.490495    9.083238    4.2706      3.7192268 ], shape=(10,), dtype=float32)\n",
      "tf.Tensor(\n",
      "[[-0.6190316  -0.5876087 ]\n",
      " [ 0.5358889   0.24722394]\n",
      " [-1.8590969   0.35099393]\n",
      " [ 0.48034358  1.0098377 ]\n",
      " [-1.0131533   0.40261763]\n",
      " [-0.5336349  -1.3340607 ]\n",
      " [ 1.0785795  -1.6257292 ]\n",
      " [-2.3349056   0.25969207]\n",
      " [-0.67622954 -0.00874697]\n",
      " [ 1.8002969  -0.41513142]], shape=(10, 2), dtype=float32) tf.Tensor(\n",
      "[ 5.9047394   5.2544823  -1.9262878   1.9506257   1.094624    7.5417576\n",
      " 11.551098   -0.36444044  4.0743184  11.052852  ], shape=(10,), dtype=float32)\n",
      "tf.Tensor(\n",
      "[[-0.33777666  0.84412426]\n",
      " [ 0.18755092  0.8289871 ]\n",
      " [-0.33956957  1.3296462 ]\n",
      " [ 1.9133232  -1.110885  ]\n",
      " [ 2.727004    0.43749428]\n",
      " [-0.8950659   1.7331111 ]\n",
      " [-0.61422265  0.5546726 ]\n",
      " [-1.4358022   1.4705707 ]\n",
      " [-1.4476991  -1.4694403 ]\n",
      " [-1.4217857  -0.5019499 ]], shape=(10, 2), dtype=float32) tf.Tensor(\n",
      "[ 1.3840508   2.6543868  -1.444734   12.978778    6.641477   -3.7060142\n",
      " -0.02732229 -3.0561688   5.949104    2.9292116 ], shape=(10,), dtype=float32)\n",
      "tf.Tensor(\n",
      "[[ 0.18704136  0.4152795 ]\n",
      " [-0.654552    1.4070663 ]\n",
      " [ 1.1959699  -1.5553602 ]\n",
      " [-0.10809617 -0.25732997]\n",
      " [-2.348344   -1.3877225 ]\n",
      " [ 0.50251377  0.00850612]\n",
      " [ 1.1469071  -0.6233338 ]\n",
      " [ 0.7784199  -0.36735997]\n",
      " [ 1.0757899  -0.29876277]\n",
      " [ 0.02688249  1.5743372 ]], shape=(10, 2), dtype=float32) tf.Tensor(\n",
      "[ 2.6876926 -1.873164  11.6523905  4.37753    2.1923375  4.672456\n",
      "  9.420513   8.242191   7.517044  -1.0369403], shape=(10,), dtype=float32)\n",
      "tf.Tensor(\n",
      "[[-0.22724836 -0.87553936]\n",
      " [-2.272581   -0.2489168 ]\n",
      " [-1.0800656  -1.7219275 ]\n",
      " [ 0.2830607  -2.1005182 ]\n",
      " [ 0.75200754 -0.7708648 ]\n",
      " [ 2.2053704  -0.6796036 ]\n",
      " [-0.8684039   0.70781076]\n",
      " [ 0.5699387   1.2102743 ]\n",
      " [ 0.59521407  0.54404116]\n",
      " [ 1.8972359  -0.17731154]], shape=(10, 2), dtype=float32) tf.Tensor(\n",
      "[ 7.0627556  -0.8216634   6.7735415  12.528423    7.792963   11.08244\n",
      " -0.02276625  2.3496516   3.9485497   9.084881  ], shape=(10,), dtype=float32)\n"
     ]
    }
   ],
   "source": [
    "dataset=tf.data.Dataset.from_tensor_slices((features,labels))\n",
    "train_db = tf.data.Dataset.from_tensor_slices((features, labels)).batch(10)\n",
    "for(x,y) in train_db:\n",
    "    print(x,y)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "pycharm": {
     "name": "#%% md\n"
    }
   },
   "source": [
    "定义模型,tensorflow 2.0推荐使用keras定义网络，故使用keras定义网络\n",
    "我们先定义一个模型变量`model`，它是一个`Sequential`实例。\n",
    "在keras中，`Sequential`实例可以看作是一个串联各个层的容器。\n",
    "在构造模型时，我们在该容器中依次添加层。\n",
    "当给定输入数据时，容器中的每一层将依次计算并将输出作为下一层的输入。\n",
    "重要的一点是，在keras中我们无须指定每一层输入的形状。\n",
    "因为为线性回归，输入层与输出层全连接，故定义一层"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": true,
    "pycharm": {
     "name": "#%%\n"
    }
   },
   "outputs": [],
   "source": [
    "from tensorflow import keras\n",
    "model = keras.Sequential()\n",
    "model.add(keras.layers.Dense(1))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "pycharm": {
     "name": "#%% md\n"
    }
   },
   "source": [
    "定义损失函数和优化器：损失函数为mse，优化器选择sgd随机梯度下降\n",
    "在keras中，定义完模型后，调用`compile()`方法可以配置模型的损失函数和优化方法。定义损失函数只需传入`loss`的参数，keras定义了各种损失函数，并直接使用它提供的平方损失`mse`作为模型的损失函数。同样，我们也无须实现小批量随机梯度下降，只需传入`optimizer`的参数，keras定义了各种优化算法，我们这里直接指定学习率为0.01的小批量随机梯度下降`tf.keras.optimizers.SGD(0.03)`为优化算法"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "collapsed": true,
    "pycharm": {
     "name": "#%%\n"
    }
   },
   "outputs": [],
   "source": [
    "model.compile(optimizer=tf.keras.optimizers.SGD(0.01),\n",
    "              loss='mse')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "pycharm": {
     "name": "#%% md\n"
    }
   },
   "source": [
    "在使用keras训练模型时，我们通过调用`model`实例的`fit`函数来迭代模型。`fit`函数只需传入你的输入x和输出y，还有epoch遍历数据的次数，每次更新梯度的大小batch_size, 这里定义epoch=3，batch_size=10。\n",
    "使用keras甚至完全不需要去划分数据集"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "pycharm": {
     "name": "#%%\n"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Train on 1000 samples\n",
      "Epoch 1/3\n",
      "1000/1000 [==============================] - 1s 1ms/sample - loss: 9.5898\n",
      "Epoch 2/3\n",
      "1000/1000 [==============================] - 0s 224us/sample - loss: 1.1697\n",
      "Epoch 3/3\n",
      "1000/1000 [==============================] - 0s 296us/sample - loss: 0.9868\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "<tensorflow.python.keras.callbacks.History at 0x323d836d68>"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "model.fit(features,labels,epochs=3, batch_size=10)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "pycharm": {
     "name": "#%% md\n"
    }
   },
   "source": [
    "下面我们分别比较学到的模型参数和真实的模型参数。我们可以通过model的`get_weights()`来获得其权重（`weight`）和偏差（`bias`）。学到的参数和真实的参数很接近。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {
    "pycharm": {
     "name": "#%%\n"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "([2, -3.4], array([[ 1.9412669],\n",
       "        [-3.3460715]], dtype=float32))"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "true_w, model.get_weights()[0]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(4.2, array([4.2120686], dtype=float32))"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "true_b, model.get_weights()[1]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.1"
  },
  "pycharm": {
   "stem_cell": {
    "cell_type": "raw",
    "metadata": {
     "collapsed": false
    },
    "source": []
   }
  }
 },
 "nbformat": 4,
 "nbformat_minor": 1
}
